package com.itheima.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ieheiima.health.common.MessageConst;
import com.ieheiima.health.entity.Result;
import com.itheima.health.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author weizhongli
 * @Date 2020/3/26
 * @Version v1.0
 * @Description 用户业务的控制器
 **/
@RestController
@RequestMapping("web/user")
public class UserController {

    @Reference
    private UserService userService;

    @RequestMapping("login")
    public Result login(String username, String password) {
        System.out.println("health_oms_backed===u" + username + ", p:" + password);
        //调用service方法
        if (userService.login(username,password)){
            //返回正确
            System.out.println("login success");
            return new Result(true, MessageConst.ACTION_SUCCESS);
        }else{
            //返回失败
            System.out.println("login fail");
            return  new Result(false,MessageConst.ACTION_FAIL);
        }
    }
}
